<template>
  <div class="dialog">
    <el-dialog title="出鱼任务详情" :visible.sync="showDialog" width="65%" top="0" :close-on-click-modal="false"
      @close="cancel">
      <el-form ref="ruleForm" label-position="left" :model="formData" class="el-form">
        <el-form-item label="任务名称" class="w50p" prop="fishOutTaskName">
          <el-input v-model="formData.fishOutTaskName" clearable placeholder="暂无数据" />
        </el-form-item>
        <el-form-item label="创建人" class="w50p" prop="staffName">
          <el-input v-model="formData.staffName" clearable placeholder="暂无数据" />
        </el-form-item>
        <el-form-item label="产出码单号" class="w100p" prop="codeNumber">
          <el-input v-model="formData.codeNumber" type="textarea" autosize clearable placeholder="暂无数据" />
        </el-form-item>
        <!-- <el-row :gutter="15"> -->
        <el-table ref="rightTableData" :data="rightTableData" tooltip-effect="dark" highlight-current-row border stripe
          class="rightTableData">
          <el-table-column type="index" label="序号" width="50" />
          <el-table-column label="出鱼类型" prop="fishTypeStr" align="center" min-width="90" />
          <el-table-column label="鱼品种" prop="varietyName" align="center" min-width="90" />
          <el-table-column label="出鱼规格(斤)" prop="specification" align="center" min-width="90" />
          <el-table-column label="产出数量(尾)" prop="num" min-width="100" />
          <el-table-column label="产出重量(斤)" prop="weight" min-width="100" />
          <el-table-column label="产出备注" prop="remark" min-width="100" />
          <!-- <el-table-column label="操作" min-width="80">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  style="color:red;text-decoration: underline;"
                  size="small"
                  @click.native.prevent="
                    deleteRow(scope.$index, rightTableData)
                  "
                >删除</el-button>
              </template>
            </el-table-column> -->
          <template slot="empty">
            <div>暂无数据</div>
          </template>
        </el-table>
        <!-- </el-row> -->
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { mymixin } from "@/utils/mixin";

import FishOutTaskApi from "@/api/output-manage/fish-out-task";
import InputPondDetailApi from "@/api/inputPond/input-pond-detail"
export default {
  name: "",
  components: {},
  mixins: [mymixin],
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    completeInfoObject: {
      type: [Object],
      default: () => {
        return {};
      },
    },
  },
  data () {
    return {
      formData: {},
      rightTableData: [],
      specificationList: [],
      currentBatchId: 1,
      showDialog: this.show
    };
  },
  computed: {
    ...mapGetters({
      judgePermission: "permission/judgePermission",
    }),
  },
  watch: {
    show (v) {
      this.showDialog = v;
    },
    completeInfoObject (v) {
      this.formData = {
        fishOutTaskName: v.fishOutTaskName,
        staffName: v.staffName,
        codeNumber: v.codeNumber
      }
      this.queryInputPondDetail(v)
    },
  },
  created () { },
  mounted () {
  },
  methods: {
    queryInputPondDetail (v) {
      let params = {
        fishOutTaskId: v.fishOutTaskId
      }
      FishOutTaskApi.queryDetail(params).then(res => {
        if (res.success) {
          this.rightTableData = res.data;
        }
      })
    },
    // 修改一行数据
    editRow (index, rows) {
      let params = {
        inputPondDetailId: rows.inputPondDetailId,
        specificationId: rows.specificationId,
        inputNum: rows.inputNum,
        inputWeight: rows.inputWeight,
      }
      InputPondDetailApi.edit(params).then(res => {
        if (res.success === true) {
          this.$message.success("修改成功！");
        } else {
          this.$message.error(res.message);
        }
      })
    },
    // 删除一行数据
    deleteRow (index, rows) {
      this.$confirm("此操作将永久删除该项, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        
      }).then(() => {
        let params = {
          id: rows.inputPondDetailId,
        }
        InputPondDetailApi.delById(params).then(res => {
          if (res.success === true) {
            this.$message.success("删除成功！");
            this.rightTableData.splice(index, 1);
          } else {
            this.$message.error(res.message);
          }
        })
      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除"
        });
      });
    },
    changeCurrentPage (currentPage) {
      this.currentPage = currentPage;
      this.queryPageList();
    },
    close () {
      this.$emit("closeDialog");
    },
    cancel () {
      this.$emit("cancelDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
.pagination {
  position: absolute;
  right: 0px;
  bottom: -40px;
}

.el-table {
  position: relative;
}

::v-deep .el-dialog__body {
  padding: 30px 20px 50px 20px;
}

::v-deep .el-form {
  display: flex;
  flex-wrap: wrap;
  padding: 2px;
  width: 100%;

  .el-form-item__label {
    color: #000;
    white-space: nowrap;
    font-size: 14px;
    min-width: 80px;
    text-align: end;
  }
}

::v-deep .el-form-item--medium {
  display: flex;
  margin-bottom: 0;
  padding: 10px;

  .el-form-item__content {
    display: flex;
    align-items: center;
    width: 100%;
    line-height: 36px;

    >span {
      white-space: nowrap;
      min-width: 50px;
      text-align: end;
      color: #000;
    }

    .el-input {
      width: 100%;
    }
  }

  .el-form-item__label {
    line-height: 36px;
  }
}

::v-deep {
  .el-row {
    margin: 20px 0;
    padding-bottom: 20px;
    width: 100%;
    border: #000 1px solid;

    // border-bottom-width: 0;
    // &:last-child {
    //   border-bottom-width: 1px;
    // }
    .el-col {
      border: #000 1px solid;
      border-bottom-width: 1;
      border-right-width: 0;
      border-top-width: 0;

      &:first-child {
        border-left-width: 0;
      }
    }
  }
}
</style>
